package com.system.common.controller.role;

import com.system.common.request.BaseReq;
import com.system.common.request.role.AssignPurReq;
import com.system.common.request.role.SaveRoleReq;
import com.system.common.response.BaseResp;
import com.system.common.response.PageResp;
import com.system.common.service.role.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/admin/role")
public class RoleController {

    @Autowired
    private RoleService roleService;


    @RequestMapping(value = "/list", method = {RequestMethod.GET})
    public String List() {
        return "/admin/role/list";
    }


    @RequestMapping(value = "/search", method = {RequestMethod.GET})
    @ResponseBody
    public PageResp search(SaveRoleReq req) {
        return roleService.search(req);
    }



    @RequestMapping(value = "/save", method = {RequestMethod.POST})
    @ResponseBody
    public BaseResp save(SaveRoleReq req) {

        return roleService.saveRole(req);
    }

    @RequestMapping(value = "/del", method = {RequestMethod.POST})
    @ResponseBody
    public BaseResp del(BaseReq req) {
        return  roleService.delRole(req);
    }


    @RequestMapping(value = "/queryAllRole", method = {RequestMethod.GET})
    @ResponseBody
    public PageResp queryAllRole(BaseReq req){
        return roleService.queryAllRole(req);
    }


    @RequestMapping(value = "/assignPur", method = {RequestMethod.POST})
    @ResponseBody
    public BaseResp assignPur(@RequestBody AssignPurReq req) {
        return  roleService.assignPur(req);
    }

}
